USE [CTEM-DB-v1]
GO

/****** Object:  StoredProcedure [dbo].[WorkerSalary_UpdateTotalSalary]    Script Date: 02/10/2012 11:13:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		TienDH
-- Create date: 12/05/2011
-- Description:	Get full employee's information
-- =============================================
CREATE PROCEDURE [dbo].[WorkerSalary_UpdateTotalSalary]
    @workersSalaryID        bigint,
    @ConstructionID			bigint
AS
	DECLARE @totalSalary	bigint
BEGIN
	SET @totalSalary = (SELECT SUM(TotalSalary) FROM Worker WHERE WorkersSalaryID = @workersSalaryID)
	IF @totalSalary IS NULL
	SET @totalSalary=0
	UPDATE  [WorkersSalary]			
	SET    TotalSalary =@totalSalary,
		   TotalCost = OthersCost + @totalSalary			
	WHERE	WorkersSalaryID = @workersSalaryID
END
EXEC Estimate_UpdateTotalWorkerCost @ConstructionID 



GO

